﻿CREATE PROCEDURE [dbo].[yaf_user_changepassword](
                @UserID      INT,
                @OldPassword NVARCHAR(32),
                @NewPassword NVARCHAR(32))
AS
    BEGIN
        DECLARE  @CurrentOld NVARCHAR(32)
        SELECT @CurrentOld = Password
        FROM   yaf_User
        WHERE  UserID = @UserID
        IF @CurrentOld <> @OldPassword
        BEGIN
            SELECT Success = CONVERT(BIT,0)
            RETURN
        END
        UPDATE yaf_User
        SET    Password = @NewPassword
        WHERE  UserID = @UserID
        SELECT Success = CONVERT(BIT,1)
    END


